#ifndef DISCUSS_COMMAND_IN_H_
#define DISCUSS_COMMAND_IN_H_
#include "command.h"

#pragma pack(1)
namespace Cmd
{
        namespace Discuss
        {
                //  cmd declaration
                enum {
                        CMDIN_LOGIN             = 0x0010,	// 登录DiscussServer验证指令
                        CMDIN_FORWARD           = 0x0011,	// 转发的指令
                        CMDIN_SESSION           = 0x0012,	// 与SessionServer交互的指令
                };
                enum { //CMDIN_LOGIN
                        SCMDIN_LOGIN                            = 0x0001,	//请求登录DiscussServer
                        SCMDIN_LOGIN_RESPONCE                   = 0x0002,	//登录DiscussServer返回
                };
                enum { //CMDIN_FORWARD
                        SCMDIN_FORWARD_DISCUSS                  = 0x0001,       //转发到DiscussServer的指令
                        SCMDIN_FORWARD_USER                     = 0x0002,	//DiscussServer转发指令给用户
                };
                enum { //CMDIN_SESSION
                        SCMDIN_SESSION_NOTIFY_USER_STATE        = 0x0001,
                        SCMDIN_SESSION_NOTIFY_USER_NICKNAME     = 0x0002,
                        SCMDIN_SESSION_NEW_USER_STATE_REQ       = 0x0003,
                        SCMDIN_SESSION_NEW_USER_STATE_RES       = 0x0004,
                        SCMDIN_SESSION_QUERY_USER_STATE_REQ     = 0x0005,
                        SCMDIN_SESSION_QUERY_USER_STATE_RES     = 0x0006,
                };


                //	cmd definition
                struct stLoginCmd:t_NullCmd
                {
                        stLoginCmd():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN)
                        {
                                dest_type_ = DISCUSSSERVER;
                                server_type_ = 0;
                                server_id_ = 0;
                        }
                        WORD dest_type_;
                        WORD server_type_;
                        DWORD server_id_;
                };
                struct stLoginResponce:t_NullCmd
                {
                        stLoginResponce():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN_RESPONCE)
                        {
                        }
                };

                struct stForwardDiscuss:t_NullCmd
                {
                        stForwardDiscuss():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_DISCUSS)
                        {
                                user_id_ = 0;
                                size_ = 0;
                        }
                        DWORD user_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize() const
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardUser:t_NullCmd
                {
                        stForwardUser():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_USER)
                        {
                                user_id_ = 0;
                                size_ = 0;
                        }
                        DWORD user_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize() 
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stSessionNotifyUserState:
                        t_NullCmd
                {
                        stSessionNotifyUserState():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_NOTIFY_USER_STATE)
                        {
                                discuss_id_ = 0 ;
                                user_id_ = 0;
                                state_ = USER_STATE_OFFLINE;
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                        BYTE state_;
                };
                struct stSessionNotifyUserNickname:
                        t_NullCmd
                {
                        stSessionNotifyUserNickname():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_NOTIFY_USER_NICKNAME)
                        {
                                discuss_id_ = 0;
                                user_id_ = 0;
                                bzero(nick_name_, sizeof(nick_name_));
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                        char nick_name_[MAX_NAME_SIZE+1];
                };
                struct stSessionNewUserStateReq:
                        t_NullCmd
                {
                        stSessionNewUserStateReq():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_NEW_USER_STATE_REQ)
                        {
                                discuss_id_ = 0;
                                user_id_    = 0;
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                };
                struct stSessionNewUserStateRes:
                        t_NullCmd
                {
                        stSessionNewUserStateRes():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_NEW_USER_STATE_RES)
                        {
                                discuss_id_ = 0;
                                user_id_    = 0;
                                state_      = USER_STATE_ONLINE;
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                        BYTE  state_;
                };
                struct stSessionQueryUserStateReq:
                        t_NullCmd
                {
                        stSessionQueryUserStateReq():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_QUERY_USER_STATE_REQ)
                        {
                                discuss_id_ = 0;
                                user_id_    = 0;
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                };
                struct stSessionQueryUserStateRes:
                        t_NullCmd
                {
                        stSessionQueryUserStateRes():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_QUERY_USER_STATE_RES)
                        {
                                discuss_id_ = 0;
                                user_id_    = 0;
                                state_      = USER_STATE_ONLINE;
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                        BYTE  state_;
                };
        }; //namespace Discuss
}; //namespace Cmd
#pragma pack() //pack(1)

#endif //DISCUSS_COMMAND_H_
